﻿@{
    ViewBag.Title = "List";
    Layout = "~/Views/Shared/InfoMaste.cshtml";
}
<script src="~/Js/Global.js?v=202407012"></script>
<script type="text/javascript">
    function doSearch() {
        $('#tg').treegrid('load', {
        });
    }

    //新增数据
    function addLKWareHouse() {
        $('#dlg').dialog('open').dialog('setTitle', '新增');
        $('#fm').form('clear');
        InitCompanyById(CompanyId, companytoolbar)
        $('#ParentId').combotree({
            url: "/BasicManage/GetAllHouseComboxTree",
            editable: false,
            valueField: 'Id',
            textField: 'WareHouseName'
        });
        url = '/BasicManage/AddLKWareHouse';
    }
    //编辑数据
    function editLKWareHouse() {
        var row = $('#tg').treegrid('getSelected');
        if (!row) {
            Helper.Show("请选择数据编辑!");
            return false;
        }
        $('#dlg').dialog('open').dialog('setTitle', '编辑');
        InitCompanyById(CompanyId, companytoolbar)
        $('#ParentId').combotree({
            url: "/BasicManage/GetAllHouseComboxTree",
            editable: false,
            valueField: 'Id',
            textField: 'WareHouseName'
        });
        $('#fm').form('load', row);
        url = '/BasicManage/EditLKWareHouse';
    }

    function saveLKWareHouse() {
        $('#fm').form('submit', {
            url: url,
            onSubmit: function () {
                return $(this).form('validate');
            },
            success: function (json) {
                var json = eval('(' + json + ')');
                $.messager.show({
                    title: '消息提示',
                    msg: json.Msg
                });
                if (json.Success) {
                    $('#dlg').dialog('close');
                    doSearch();
                }
            }
        });
    }

    function delLKWareHouse() {
        var row = $('#tg').treegrid('getSelected');
        if (!row) {
            Helper.Show('请选择需要删除的信息?');
            return false;
        }
        $.messager.confirm('提示信息', '您确认要删除吗?', function (r) {
            if (!r) { return false; }
            $.post("/BasicManage/DeleteLKWareHouse", { id: row.Id }, function (json) {
                Helper.Show(json.Msg);
                if (json.Success) {
                    doSearch();
                }
            });
        });
    }

    function querycompany() {
        $("#CompanyId").combogrid("grid").datagrid("reload", { "Company": $("#CompanyText").val() });
    }

</script>
<div id="tb" style="padding: 3px; height: auto;">
    <a href="javascript:" class="easyui-linkbutton" iconcls="icon-add" plain="true" onclick="addLKWareHouse()">新增</a>
    <a href="javascript:" class="easyui-linkbutton" iconcls="icon-edit" plain="true" onclick="editLKWareHouse()">编辑</a>
    <a href="javascript:" class="easyui-linkbutton" iconcls="icon-no" plain="true" onclick="delLKWareHouse()">删除</a>
</div>
<table id="tg" title="仓库" toolbar="#tb" class="easyui-treegrid" style="width:100%; height: 600px;"
       data-options="
				url: '/BasicManage/GetLKWareHouse',
				method: 'post',
				rownumbers: true,
				idField: 'Id',
				treeField: 'WareHouseName'
			">
    <thead>
        <tr>

            <th data-options="field:'WareHouseName'" width="300">名称</th>
            <th data-options="field:'Remark'" width="450">描述</th>
            <th data-options="field:'CompanyName'" width="450">公司</th>
            <th data-options="field:'Volume'" width="100">最大容量</th>
        </tr>
    </thead>
</table>

<div id="dlg" class="easyui-dialog" title="新增" data-options="iconCls:'icon-save'"
     closed="true" style="width: 450px; height: 380px; padding: 10px 20px;" buttons="#dlg-buttons" modal="true">
    <form id="fm" method="post" novalidate>
        <input type="hidden" id="Id" name="Id" />
        <div class="fitem">
            <label>
                公司 :
            </label>
            <input class="easyui-combobox" id="CompanyId" name="CompanyId" style="width: 173px; height: 30px;" autocomplete="off" />
        </div>
        <div class="fitem">
            <label>
                所属父级 :
            </label>
            <input class="easyui-combobox" id="ParentId" name="ParentId" style="width: 173px; height: 30px;" autocomplete="off" />
        </div>
        <div class="fitem">
            <label>
                名称 :
            </label>
            <input class="easyui-validatebox textbox" name="WareHouseName" data-options="required:true"
                   style="width: 173px; height: 30px;" autocomplete="off" />
        </div>
        <div class="fitem">
            <label>
                描述 :
            </label>
            <input class="easyui-validatebox textbox" name="Remark"
                   style="width: 173px; height: 30px;" autocomplete="off" />
        </div>
        <div class="fitem">
            <label>
                最大容量 :
            </label>
            <input class="easyui-validatebox textbox" name="Volume" data-options="required:true,prompt:'1~15位的数字'"
                   style="width: 173px; height: 30px;" autocomplete="off" />
        </div>
    </form>
    <div id="companytoolbar">
        <input id="CompanyText" class="easyui-textbox " style="width: 173px; height: 30px;" />
        <a href="javascript:" class="easyui-linkbutton" plain="true" iconcls="icon-search" onclick="querycompany()">查询</a>
    </div>
</div>
<div id="dlg-buttons">
    <a href="javascript:void(0)" class="easyui-linkbutton" iconcls="icon-ok" onclick="saveLKWareHouse()">保存</a>
    <a href="javascript:void(0)" class="easyui-linkbutton" iconcls="icon-cancel" onclick="javascript:$('#dlg').dialog('close')">取消</a>
</div>
